import 'package:equatable/equatable.dart';
import 'package:backend.core/core/domain/entities/api/app_store/api_app_store_transaction_revocation_reason.dart';

const kApiAppStoreIssueWithinAppTransactionRevocationReasonValue = 'issue_within_app';
const kApiAppStoreOtherReasonTransactionRevocationReasonValue = 'other_reason';

class ApiAppStoreTransactionRevocationReasonDto extends Equatable {
  const ApiAppStoreTransactionRevocationReasonDto._internal({
    required this.revocationReasonString,
  });

  final String revocationReasonString;

  @override
  List<Object?> get props {
    return [
      revocationReasonString,
    ];
  }

  factory ApiAppStoreTransactionRevocationReasonDto.fromEntity(
      ApiAppStoreTransactionRevocationReason revocationReason) {
    late final String revocationReasonString;

    if (revocationReason == ApiAppStoreTransactionRevocationReason.issueWithinApp) {
      revocationReasonString = kApiAppStoreIssueWithinAppTransactionRevocationReasonValue;
    } else if (revocationReason == ApiAppStoreTransactionRevocationReason.otherReason) {
      revocationReasonString = kApiAppStoreOtherReasonTransactionRevocationReasonValue;
    }

    return ApiAppStoreTransactionRevocationReasonDto._internal(
      revocationReasonString: revocationReasonString,
    );
  }

  @override
  String toString() {
    return revocationReasonString;
  }
}
